//============================================================================
// Name        : bt.cpp
// Author      : bt
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
void Swap(int &a,int &b)
{
	int tam =a;
	a = b;
	b = tam;
}

void Write(ofstream &writefile,int a[],int n)
{
	writefile.open("/home/olovei/workspace/bt/src/chan.txt");
	for(int i=0;i<n;i++)
	{
		cout<<"a["<<i<<"]: ";
		cin>>a[i];
		writefile<<" "<<a[i];
	}
	writefile.close();
}
void process(ofstream &writefile,int a[],int n)
{
	writefile.open("/home/olovei/workspace/bt/src/le.txt");
	for(int i=0;i<n;i++)
	{
		if(a[i]%2!=0)
		{
			writefile<<" "<<a[i];
		}
	}
	writefile.close();
}
void Sum(ofstream &writefile,int a[],int n)
{
	writefile.open("/home/olovei/workspace/bt/src/tong.txt");
	int sum = 0;
	for(int i=0;i<n;i++)
	{
		sum = sum+a[i];

	}
	writefile<<" "<<sum;
	writefile.close();
}
void Out(ifstream&readfile,int a[],int n)
{
	char k;
	readfile.open("/home/olovei/workspace/bt/src/chan.txt");
	while(readfile.eof()==0)
	{
		readfile.get(k);
		if(readfile.eof()==0)
		{
			cout<<" "<<k;
		}

	}
	readfile.close();
}
int main(void)
{
	ofstream ttfile;
	ifstream infile;
	int n,a[10];
	printf("cin n: ");
	cin>>n;
	Write(ttfile,a,n);
	process(ttfile,a,n);
	Sum(ttfile,a,n);
	Out(infile,a,n);
	ttfile.close();
	infile.close();
	return 0;
}
